{% set pypi_name = 'python-glanceclient' %}
{% set upstream_version = upstream_version('3.2.2') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Epoch:          {{ epoch('python-glanceclient') }}
Summary:        Python API and CLI for OpenStack Glance
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('PrettyTable') }}
BuildRequires:  {{ py3('ddt') }}
BuildRequires:  {{ py3('fixtures') }}
BuildRequires:  {{ py3('python-keystoneclient') }}
BuildRequires:  {{ py3('mock') }}
BuildRequires:  {{ py3('os-client-config') }}
BuildRequires:  {{ py3('oslo.utils') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('pyOpenSSL') }}
BuildRequires:  {{ py3('requests-mock') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('testscenarios') }}
BuildRequires:  {{ py3('testtools') }}
BuildRequires:  {{ py3('warlock') }}
BuildArch:      noarch

%description
This is a client for the OpenStack Glance API. There's a Python API (the
glanceclient module), and a command-line script (glance). Each implements
100% of the OpenStack Glance API.

%package -n {{ py2name(py_versions='py3') }}
Summary:        Python API and CLI for OpenStack Glance
Requires:       {{ py3('PrettyTable') }}
Requires:       {{ py3('keystoneauth1') }}
Requires:       {{ py3('oslo.i18n') }}
Requires:       {{ py3('oslo.utils') }}
Requires:       {{ py3('pbr') }}
Requires:       {{ py3('pyOpenSSL') }}
Requires:       {{ py3('requests') }}
Requires:       {{ py3('six') }}
Requires:       {{ py3('warlock') }}
Requires:       {{ py3('wrapt') }}
%if 0%{?suse_version}
Obsoletes:      {{ py2name(py_versions='py2') }} < 2.18.0
%endif

%description -n {{ py2name(py_versions='py3') }}
This is a client for the OpenStack Glance API. There's a Python API (the
glanceclient module), and a command-line script (glance). Each implements
100% of the OpenStack Glance API.

%package -n python-glanceclient-doc
Summary:        Documentation for OpenStack Glance API Client
Group:          Documentation/HTML
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}
BuildRequires:  {{ py3('reno') }}
BuildRequires:  {{ py3('sphinxcontrib-apidoc') }}

%description -n python-glanceclient-doc
This is a client for the OpenStack Glance API. There's a Python API (the
glanceclient module), and a command-line script (glance). Each implements
100% of the OpenStack Glance API.
This package contains auto-generated documentation.

%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup

%build
%py3_build

# generate html docs
PBR_VERSION={{ upstream_version }} %sphinx_build -b html doc/source doc/build/html
PBR_VERSION={{ upstream_version }} %sphinx_build -b man doc/source doc/build/man
# remove the sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}
rm -rf doc/build/man/.{doctrees,buildinfo}

%install
%py3_install
#man pages
install -p -D -m 644 doc/build/man/glance.1 %{buildroot}%{_mandir}/man1/glance.1

%check
python3 -m stestr.cli run

%files -n {{ py2name(py_versions='py3') }}
%license LICENSE
%doc README.rst ChangeLog
%{_bindir}/glance
%{_mandir}/man1/glance.1*
%{python3_sitelib}/glanceclient
%{python3_sitelib}/*.egg-info

%files -n python-glanceclient-doc
%license LICENSE
%doc doc/build/html

%changelog
